package org.ilc.socketserver.codec;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;


public class DefaultProtocolDecoder implements ProtocolDecoder{
	private IProtocolDecoder decoder;

	public DefaultProtocolDecoder(IProtocolDecoder decoder){
		this.decoder=decoder;
	}

	@Override
	public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
		try {
			this.decoder.decode(session, in, out);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw ex;
		} finally {
			// 关闭session
			// session.close(true);
		}
		
	}

	@Override
	public void dispose(IoSession session) throws Exception {

	}

	@Override
	public void finishDecode(IoSession session, ProtocolDecoderOutput out)
			throws Exception {

	}

}
